--SELECT * FROM lion_candidate_tag_mapping
--DELETE FROM lion_candidate_tag_mapping
INSERT INTO lion_candidate_tag_mapping
SELECT 
 case len(convert(varchar(10),id))
    when 6 then '00000000-0000-0000-0000-000000' + convert(varchar(10),id)
    when 5 then '00000000-0000-0000-0000-0000000' + convert(varchar(10),id) 
    when 4 then '00000000-0000-0000-0000-00000000' + convert(varchar(10),id) 
    when 3 then '00000000-0000-0000-0000-000000000' + convert(varchar(10),id) 
    when 2 then '00000000-0000-0000-0000-0000000000' + convert(varchar(10),id) 
    when 1 then '00000000-0000-0000-0000-00000000000'+ convert(varchar(10),id) 
    end As Candidateid,
    dbo.gettagid(companyid,tag) as Tagid,
    updateddate as DateCreated
FROM srv_lnk.nchr2008.dbo.resumescore
where companyid in(select id from companyinfo) and not tag is null and len(tag)>=1

--select top 10 * from srv_lnk.nchr2008.dbo.resumescore
--order by updateddate desc

